﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharpTrainer.Objects
{
    public class PersonComparer : IEqualityComparer<Person>
    {
        public bool Equals(Person x, Person y)
        {
            if (x == null)
                return y == null;

            return x.Name == y.Name && x.Age == y.Age;
        }

        public int GetHashCode(Person obj)
        {
            if (obj == null)
                return 0;

            return obj.Name.GetHashCode();
            //return 2 * obj.Name.GetHashCode() + 3 * obj.Age.GetHashCode();
        }
    }
}
